/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.annuaireComp.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MiniK
 */
@Entity
@Table(name = "savoir_competence")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "SavoirCompetence.findAll", query = "SELECT s FROM SavoirCompetence s"),
    @NamedQuery(name = "SavoirCompetence.findByIdsavoirCompetence", query = "SELECT s FROM SavoirCompetence s WHERE s.idsavoirCompetence = :idsavoirCompetence"),
    @NamedQuery(name = "SavoirCompetence.findByLibelle", query = "SELECT s FROM SavoirCompetence s WHERE s.libelle = :libelle")})
public class SavoirCompetence implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idsavoir_competence")
    private Integer idsavoirCompetence;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "libelle")
    private String libelle;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "savoirCompetence", fetch = FetchType.EAGER)
    private List<Competence> competenceList;

    public SavoirCompetence() {
    }

    public SavoirCompetence(Integer idsavoirCompetence) {
        this.idsavoirCompetence = idsavoirCompetence;
    }

    public SavoirCompetence(Integer idsavoirCompetence, String libelle) {
        this.idsavoirCompetence = idsavoirCompetence;
        this.libelle = libelle;
    }

    public Integer getIdsavoirCompetence() {
        return idsavoirCompetence;
    }

    public void setIdsavoirCompetence(Integer idsavoirCompetence) {
        this.idsavoirCompetence = idsavoirCompetence;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    @XmlTransient
    public List<Competence> getCompetenceList() {
        return competenceList;
    }

    public void setCompetenceList(List<Competence> competenceList) {
        this.competenceList = competenceList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idsavoirCompetence != null ? idsavoirCompetence.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SavoirCompetence)) {
            return false;
        }
        SavoirCompetence other = (SavoirCompetence) object;
        if ((this.idsavoirCompetence == null && other.idsavoirCompetence != null) || (this.idsavoirCompetence != null && !this.idsavoirCompetence.equals(other.idsavoirCompetence))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.annuaireComp.entities.SavoirCompetence[ idsavoirCompetence=" + idsavoirCompetence + " ]";
    }
    
}
